package Form::PersonAndContact;
use strict;
use warnings;
use base qw(My::Form);
use Form::Field::Gender;
use Form::Field::CountryPopupMenu;
use Form::Field::CountrySelectBox;
use Form::Field::OcfCentrePopupMenu;
use Form::Field::DateField;
use Form::Field::YearRange;

sub build_form {
    my ($self) = shift;

    #
    #        'id'               => { 'type' => 'serial',    'primary_key' => 1,   'not_null' => 1 },
    #        'name'             => { 'type' => 'varchar',   'length'      => 255, 'not_null' => 1 },
    #        'family_name'      => { 'type' => 'varchar',   'length'      => 255, 'not_null' => 1 },
    #        'gender'           => { 'type' => 'varchar',   'length'      => 1,   'not_null' => 1 },
    #        'birth_date'       => { 'type' => 'datetime' },
    #        'birth_country_id' => { 'type' => 'varchar',   'length'      => 2,   'not_null' => 1 },
    #        'created'          => { 'type' => 'timestamp', 'not_null'    => 1,   'default'  => 'now' },
    #        'modified'         => { 'type' => 'timestamp', 'not_null'    => 1,   'default'  => 'now' },
    my $birth_date_field =
        Form::Field::DateField->new( 'name' => 'birth_date', 'label' => 'Date of Birth', 'required' => 1 )
        ;
    my $gender_field = Form::Field::Gender->new( 'name' => 'gender', 'label' => 'Gender', 'required' => 1 );
    my $birth_country_id =
        Form::Field::CountryPopupMenu->new( 'name'     => 'birth_country_id',
                                            'label'    => 'Country of Birth',
                                            'required' => 1
        );
    my $nationalities =
        Form::Field::CountrySelectBox->new( 'name'     => 'nationalities',
                                            'label'    => 'Nationality',
                                            'required' => 1
        );
    my $centre_affiliation =
        Form::Field::OcfCentrePopupMenu->new( 'name' => 'ocf_centre', 'label' => 'OCF Centre' );
    my $service_term =
        Form::Field::YearRange->new( 'name' => 'ocf_service_term', 'label' => 'Years of Participation' );
    my $phone_number_field =
        Form::Field::PhoneNumberField->new( 'name'   => 'phone_number',
                                            'label'  => 'Phone Number',
                                            required => 1
        );
    $self->add_fields(
        'name'        => { 'type' => 'text', 'size' => 25, 'label' => 'Name',        'required' => 1 },
        'family_name' => { 'type' => 'text', 'size' => 25, 'label' => 'Family Name', 'required' => 1 },
        'gender'      => $gender_field,
        'birth_date'         => $birth_date_field,
        'birth_country_id'   => $birth_country_id,
        'nationalities'      => $nationalities,
        'centre_affiliation' => $centre_affiliation,
        'ocf_service_term'   => $service_term,
        'email_address' => { 'type' => 'email', 'size' => 50, 'label' => 'Email Address', 'required' => 1 }
        ,
        'phone_number' => $phone_number_field,
    );
} ## end sub build_form
1;
